!function(){
    function initSetState() {
        $('.role').each(function () {
            var $id =$(this).parent().attr('href').substr(26);
            $(this).attr('src','/backend/img/member/ico'+($id%20+1)+'.png');
        });

        $('.drop').on('click', function(){
            var obj = $(this);
            var member_id = obj.attr('member_id');
            var url = '/business/member/deletemember';
            layer.confirm(
                '<div class="text-center">确认作废吗？</div>作废后所有用户列表不显示该用户',
                {
                    title: '系统提示',
                    btn: ['确 定', '取 消']
                },
                function(index){
                    layer.close(index);
                    layer.load();
                    $.get(
                        url,
                        {member_id: member_id},
                        function(data){
                            if(data == 1) {
                                location.reload(true);
                            } else {
                                layer.closeAll();
                                layer.alert(data);
                            }
                        },
                        'json'
                    );
                },
                function(index){
                    layer.close(index);
                }
            );
        });
    }
    $(function(){
        initSetState();

    })
}();